//
//  VaccinationController.h
//  Cabinet
//
//  Created by Florent Montsegur on 12/07/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "Person.h"
#import "CabinetDefines.h"
#import "Vaccination.h"
#import "Rang.h"


@interface VaccinationController : NSWindowController<NSTableViewDataSource> {
@private
    NSManagedObjectContext *mManagedObjectContext;
    
    Person *mPerson;
    
    NSTextField *__unsafe_unretained mNom;
    NSTextField *__unsafe_unretained mPrenom;
    NSTextField *__unsafe_unretained mAge;
    NSDatePicker *__unsafe_unretained mNaissance;
    
    NSDatePicker *__unsafe_unretained mVaccinationDate;
    NSDatePicker *__unsafe_unretained mRappelDate;
    NSTextField *__unsafe_unretained mVaccinNom;
    NSTextField *__unsafe_unretained mVaccinCode;
    NSTextField *__unsafe_unretained mRang;
    NSTextField *__unsafe_unretained mLot;
    
    NSTableView *__unsafe_unretained mVacinationsHistorique;
    
    NSArray *mVacinations;
    
    NSButtonCell *__unsafe_unretained mEnfant;
    NSButtonCell *__unsafe_unretained mMadame;
    NSButtonCell *__unsafe_unretained mMademoiselle;   
    NSButtonCell *__unsafe_unretained mMonsieur;
    
    NSEntityDescription *mRangEntity;
    NSEntityDescription *mVaccinEntity;
    NSEntityDescription *mVaccinationEntity;
    
    NSButton *__unsafe_unretained mEffacerRappel;
}

@property (nonatomic, strong) NSManagedObjectContext * mManagedObjectContext;

@property (unsafe_unretained) IBOutlet NSTextField *mNom;
@property (unsafe_unretained) IBOutlet NSTextField *mPrenom;
@property (unsafe_unretained) IBOutlet NSTextField *mAge;
@property (unsafe_unretained) IBOutlet NSDatePicker *mNaissance;
@property (unsafe_unretained) IBOutlet NSTableView *mVacinationsHistorique;

@property (unsafe_unretained) IBOutlet NSDatePicker *mVaccinationDate;
@property (unsafe_unretained) IBOutlet NSDatePicker *mRappelDate;

@property (unsafe_unretained) IBOutlet NSTextField *mVaccinNom;
@property (unsafe_unretained) IBOutlet NSTextField *mVaccinCode;
@property (unsafe_unretained) IBOutlet NSTextField *mRang;
@property (unsafe_unretained) IBOutlet NSTextField *mLot;

@property (unsafe_unretained) IBOutlet NSButtonCell *mEnfant;
@property (unsafe_unretained) IBOutlet NSButtonCell *mMadame;
@property (unsafe_unretained) IBOutlet NSButtonCell *mMademoiselle;
@property (unsafe_unretained) IBOutlet NSButtonCell *mMonsieur;

@property (nonatomic, strong) NSEntityDescription *mRangEntity;
@property (nonatomic, strong) NSEntityDescription *mVaccinEntity;
@property (nonatomic, strong) NSEntityDescription *mVaccinationEntity;

@property (unsafe_unretained) IBOutlet NSButton *mEffacerRappel;

// NSTableViewDataSource
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex;

- (IBAction)okAction:sender;
- (IBAction)annulerAction:sender;
- (IBAction)effacerRappel:sender;

- (IBAction)searchRankAction:sender;
- (IBAction)searchVaccinAction:sender;

-(void) closeWindow;
-(void) setPerson:(Person*)aPerson;
-(void) showPerson:(Person*)aPerson;
-(void) setSelectedSex:(NSNumber*)aSexValue;
-(NSNumber*) getSelectedSex;
-(NSString *) formatInput:(NSTextField*)aTextField;

- (void) fillVaccination:(Vaccination*)aVaccination;
-(Rang*)getRang:(NSString*)aNom;
-(Vaccin*)getVaccin:(NSString*)aNom;

@end
